import type { PageParam, PageResult } from '@vben/request';

import { requestClient } from '#/api/request';

export namespace AiFormTagApi {
  /** 表单标签信息 */
  export interface FormTag {
    id: number; // 表单标签ID
    name?: string; // 标签名称
    icon: string; // 标签图标
    color: string; // 颜色
    sort: number; // 排序
    systemFlag?: boolean; // 是否系统内置
    templatesCount: number; // 表单个数
  }
}

/** 查询表单标签分页 */
export function getFormTagPage(
  data: PageParam,
  desensitize: boolean,
  encrypt: boolean,
) {
  return requestClient.post<PageResult<AiFormTagApi.FormTag>>(
    '/ai/form-tag/page',
    data,
    {
      desensitize,
      encrypt,
    },
  );
}

/** 查询表单标签详情 */
export function getFormTag(id: number) {
  return requestClient.get<AiFormTagApi.FormTag>(`/ai/form-tag/get?id=${id}`);
}

/** 新增表单标签 */
export function createFormTag(data: AiFormTagApi.FormTag) {
  return requestClient.post('/ai/form-tag/create', data);
}

/** 修改表单标签 */
export function updateFormTag(data: AiFormTagApi.FormTag) {
  return requestClient.put('/ai/form-tag/update', data);
}

/** 删除表单标签 */
export function deleteFormTag(id: number) {
  return requestClient.delete(`/ai/form-tag/delete?id=${id}`);
}

/** 批量删除表单标签 */
export function deleteFormTagList(ids: number[]) {
  return requestClient.delete(`/ai/form-tag/delete-list?ids=${ids.join(',')}`);
}

/** 导出表单标签 */
export function exportFormTag(params: any) {
  return requestClient.download('/ai/form-tag/export-excel', { params });
}
